package jdbc1;


import jdbc.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo3 {
    public static void main(String[] args) {
        try(
                Connection connection = DBUtil.getConnection();
        ) {
          Statement state = connection.createStatement();
          String sql = "SELECT id,name,age,salary*12 sal,comm,gender "+
                       "FROM teacher ";
            System.out.println(sql);
            ResultSet rs = state.executeQuery(sql);
            while(rs.next()){
                int id = rs.getInt("id");
                String name = rs.getString("name");
                int age = rs.getInt("age");
                int salary = rs.getInt("salary");
                int comm = rs.getInt("comm");
                String gender = rs.getString("gender");
                System.out.println(id+","+name+","+age+","+salary+","+comm+","+gender);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
